import { request } from "./request";

async function listRecord(start, length) {
  const response = await request(`/record/?start=${start}&len=${length}`, "GET", null, true);
  if (!Array.isArray(response.list)) {
    throw Error("Invalid list response");
  }
  if (typeof response.fullLength != "number") {
    throw Error("Invalid length response");
  }
  return response;
}


async function getStat(start, end, type){
  const response = await request(`/record/stat?start=${start}&end=${end}&type=${type}`, "GET", null, true);
  if (!Array.isArray(response)) {
    throw Error("Invalid list response");
  }
  return response;
}
export { listRecord, getStat };
